<?php

	// The command to execute the jar file
	$jar_location = "java -jar ./java_codes/ping.jar";

	session_start();

	$_SESSION['left_concept'] = htmlspecialchars($_POST['left_concept']);
	$_SESSION['right_concept'] = htmlspecialchars($_POST['right_concept']);
	$_SESSION['erreur_form'] = False;
	if (empty($_POST['left_concept']) or empty( $_POST['right_concept'])) {
		$_SESSION['err_form'] = True;
		header('Location: ../html/search.php');
	}
	else {
		if($_POST['ColorF']) {
			$_SESSION['fight'] = 'color';
			$exec_command = $jar_location . ' ' . str_replace(" ","\" \"",$_SESSION['left_concept']) . ' ' . str_replace(" ","\" \"",$_SESSION['right_concept']) . ' 2';
			$return = exec($exec_command);
			header('Location: ../html/result_step1.php');
		}
		else if ($_POST['EmotionF']) {
			$_SESSION['fight'] = 'emotion';
			$exec_command = $jar_location . ' ' . str_replace(" ","\" \"",$_SESSION['left_concept']) . ' ' . str_replace(" ","\" \"",$_SESSION['right_concept']) . ' 1';
			$return = exec($exec_command);
			header('Location: ../html/result_step1.php');
		}
	}
?>